﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.iss.inventory.Controllers;
using com.iss.inventory.Entity;

namespace Staionery_Inventory.Presentation.StationeryRequest
{
    public partial class StationeryRequestList : System.Web.UI.Page
    {
        StationeryRequestController src;
        InvManagementEntities ime;
        protected void Page_Load(object sender, EventArgs e)
        {
            //for web address security
            if (Session["empID"] == null)
            {
                Response.Redirect("~/Presentation/login.aspx");
            }

            //assign Name
            ime=new InvManagementEntities();
            Label lbl = this.Master.FindControl("lblLogInName") as Label;
            if (lbl != null)
            {
                lbl.Text = Session["UserName"].ToString();
            }

            src = new StationeryRequestController();
            gvStationeryRequestList.DataSource = src.GetAllRequestList(int.Parse(Session["ApproveID"].ToString()));
            gvStationeryRequestList.DataBind();
        }

        protected void lbStatus_Click(object sender, EventArgs e)
        {
            
            LinkButton lb = sender as LinkButton;
            GridViewRow gvr = lb.NamingContainer as GridViewRow;
            int requestList = int.Parse(gvr.Cells[0].Text);
            List<object> lst = src.ShowRequestData(requestList);
             Session["Pending"] = lst;
             Session["RequestListID"] = requestList;
            if(lb.Text=="Pending")
               Response.Redirect("~/Presentation/StationeryRequest/StationeryRequisitionForm.aspx?Status=" + lb.Text);
            else
                Response.Redirect("~/Presentation/StationeryRequest/StationeryRequisitionForm.aspx?Status=" + lb.Text);
        }



    }
}